home *** CD-ROM | disk | FTP | other *** search
- --Drags sprite 1 over sprite 2 and changes sprite 2 on mouseUp event. Sprite 1 returns to original location or hides.
- --Ex: coloring a sprite with pencils. The sprite can be changed many times.
-
- property pbasketSprite,pmaskSprite,phideDraggables
-
- on new me, tSprite,mSprite,hDrag
- set pbasketSprite=tSprite --a basket for draggables.
- set pmaskSprite=mSprite --a hilite sprite displayed on rollover of basket sprite
- set phideDraggables=hDrag --checks if draggables have to be hidden or put back
- return me
- end
-
-
- on initDragAndChange me,finalCast
- if field "new names"<>"" then
- set nLines=the linecount of member "new names"
- repeat with i=1 to nLines
- set newName=item 1 of line i of field "new names"
- set oldName=item 2 of line i of field "new names"
- if newName contains "glasses" then
- set newName=the name of member 4 of castLib finalCast
- set oldName="glasses"
- end if
- set the name of member newName of castLib finalCast=oldName
- end repeat
- put "" into field "new names"
- end if
- end
-
-
- --changes cursor to "hand" on rollover
- on psMouseEnter me,spr
- set cursor = the number of member "hand"
- set mask = the number of member "hand mask"
- set the cursor of sprite spr=[cursor,mask]
- end
-
-
- on psMouseDown me,spr,maskSpr
- puppetSprite spr,true
- if not voidP(maskSpr) then set pmaskSprite=maskSpr
- end
-
-
- --makes the sprite movable and checks if it intersects with "basket" sprite. On rollover:
- --1) if 'pmaskSprite' is 'pbasketSprite', then basket sprite itself hilites (as a mask)
- --2) if 'pmaskSprite' is not 'pbasketSprite', then another hidden sprite is displayed as a mask.
- -- In this case a basket sprite is an invisible shape, and used then basket has
- -- to be invisible and be visible as a mask (another hidden sprite) when rolled over.
- on psMouseWithin me,spr
- set the moveableSprite of sprite spr=true
- if sprite spr intersects pbasketSprite then
- set the ink of sprite pmaskSprite=4 --not copy
- set basketLoc=the loc of sprite pbasketSprite
- set the loc of sprite pmaskSprite=basketLoc
- if the regPoint of the member of sprite pmaskSprite=basketLoc then
- set the loc of sprite pmaskSprite=(basketLoc)*2
- end if
- else
- if pmaskSprite<>pbasketSprite then set the loc of sprite pmaskSprite=point(1000,1000)
- set the ink of sprite pmaskSprite=8 --matte
- end if
- updateStage
- end
-
-
-
- --replaces the member of basket sprite with a corresponding member from "draggablesswitch" cast
- on psMouseUp me,spr,finalCast,partName,ink
- set switchflag=0
- set theInk=8
- if not voidP(ink) then set theInk=ink
- set the ink of sprite pbasketSprite=theInk --matte
- if sprite spr intersects pbasketSprite then
- set dragName=the name of the member of sprite spr
- set maskName=the name of the member of sprite pmaskSprite
- if pmaskSprite<>pbasketsprite then set the loc of sprite pmaskSprite=point(1000,1000)
- --JCODE
- set theMemName = maskName&"."&dragName
- set switchMember=member theMemName of castLib "draggablesswitch"
- --END JCODE
- set the member of sprite pbasketSprite=switchMember
- set the rect of sprite pbasketSprite=the rect of sprite pmaskSprite
- updatestage
-
- --records selected image by putting it into 'finalCast'
- if not voidP(partName) then
- set the picture of member partName of castLib finalCast=the picture of the member of sprite pbasketSprite
- set the name of member partName of castLib finalCast=dragName
- put dragName&","&partName into line (the linecount of member "new names" + 1) of field "new names"
- else
- set the picture of member maskName of castLib finalCast=the picture of switchMember
- end if
-
- --records a member location on the stage as its reg. point.
- set the regPoint of member maskName of castLib finalCast=the loc of sprite pbasketSprite
- --hides draggables if needed
- if phideDraggables then set the loc of sprite spr=point(1000,1000)
- set switchflag=1
- end if
- set the moveableSprite of sprite spr=false
- if not phideDraggables or switchFlag=0 then puppetSprite spr,false
- updateStage
- return switchflag
- end
-
-
-
-
-
-